
# Toolchain settings
set(CMAKE_C_COMPILER    arm-none-eabi-gcc)
set(CMAKE_CXX_COMPILER  arm-none-eabi-g++)
set(CMAKE_AS                  arm-none-eabi-as)
set(CMAKE_AR                  arm-none-eabi-ar)
set(CMAKE_OBJCOPY             arm-none-eabi-objcopy)
set(CMAKE_OBJDUMP             arm-none-eabi-objdump)
set(CMAKE_SIZE                arm-none-eabi-size)

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

# this makes the test compiles use static library option so that we don't need to pre-set linker flags and scripts
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)

set(CMAKE_C_FLAGS   "${MCPU_FLAGS} ${VFP_FLAGS} ${SPEC_FLAGS} -fdata-sections -ffunction-sections -mlong-calls" CACHE INTERNAL "c compiler flags")
set(CMAKE_CXX_FLAGS "${MCPU_FLAGS} ${VFP_FLAGS} -fdata-sections -ffunction-sections -fno-rtti -fno-exceptions -mlong-calls" CACHE INTERNAL "cxx compiler flags")
set(CMAKE_ASM_FLAGS "${MCPU_FLAGS} -x assembler-with-cpp" CACHE INTERNAL "asm compiler flags")
set(CMAKE_EXE_LINKER_FLAGS "${MCPU_FLAGS} ${LD_FLAGS} -Wl,--gc-sections" CACHE INTERNAL "exe link flags")
SET(CMAKE_C_FLAGS_DEBUG "-Og -g -ggdb3" CACHE INTERNAL "c debug compiler flags")
SET(CMAKE_CXX_FLAGS_DEBUG "-Og -g -ggdb3" CACHE INTERNAL "cxx debug compiler flags")
SET(CMAKE_ASM_FLAGS_DEBUG "-g -ggdb3" CACHE INTERNAL "asm debug compiler flags")

SET(CMAKE_C_FLAGS_RELEASE "-O3" CACHE INTERNAL "c release compiler flags")
SET(CMAKE_CXX_FLAGS_RELEASE "-O3" CACHE INTERNAL "cxx release compiler flags")
SET(CMAKE_ASM_FLAGS_RELEASE "" CACHE INTERNAL "asm release compiler flags")










## Toolchain settings
#set(CMAKE_C_COMPILER    arm-none-eabi-gcc)
#set(CMAKE_CXX_COMPILER  arm-none-eabi-g++)
#set(AS                  arm-none-eabi-as)
#set(AR                  arm-none-eabi-ar)
#set(OBJCOPY             arm-none-eabi-objcopy)
#set(OBJDUMP             arm-none-eabi-objdump)
#set(SIZE                arm-none-eabi-size)
#
#set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
#set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
#set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
#set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
#
## this makes the test compiles use static library option so that we don't need to pre-set linker flags and scripts
#set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
#
#set(CMAKE_ASM_FLAGS "${MCPU_FLAGS} -x assembler-with-cpp -nostartfiles " CACHE INTERNAL "asm compiler flags")
#set(CMAKE_C_FLAGS   "${MCPU_FLAGS} ${VFP_FLAGS} ${SPEC_FLAGS} -nostartfiles -fdata-sections -ffunction-sections -mlong-calls" CACHE INTERNAL "c compiler flags")
#set(CMAKE_CXX_FLAGS "${MCPU_FLAGS} ${VFP_FLAGS}  -nostartfiles  -fdata-sections -ffunction-sections -fno-rtti -fno-exceptions -mlong-calls" CACHE INTERNAL "cxx compiler flags")
#set(CMAKE_EXE_LINKER_FLAGS "${MCPU_FLAGS} ${LD_FLAGS} -Wl,--gc-sections" CACHE INTERNAL "exe link flags")
##
##SET(CMAKE_C_FLAGS_DEBUG "-Og -g -ggdb3" CACHE INTERNAL "c debug compiler flags")
##SET(CMAKE_CXX_FLAGS_DEBUG "-Og -g -ggdb3" CACHE INTERNAL "cxx debug compiler flags")
##SET(CMAKE_ASM_FLAGS_DEBUG "-g -ggdb3" CACHE INTERNAL "asm debug compiler flags")
##
##SET(CMAKE_C_FLAGS_RELEASE "-O3" CACHE INTERNAL "c release compiler flags")
##SET(CMAKE_CXX_FLAGS_RELEASE "-O3" CACHE INTERNAL "cxx release compiler flags")
##SET(CMAKE_ASM_FLAGS_RELEASE "" CACHE INTERNAL "asm release compiler flags")
#
#set(LINKER_SCRIPT ${CMAKE_SOURCE_DIR}/sample_threadx.ld)
##set(CMAKE_EXE_LINKER_FLAGS " ${MCU_FLAGS}  -u _sprintf_float  -u _scanf_float -u _printf_float -fexceptions -frtti -T${LINKER_SCRIPT} -Wl,--gc-sections  -lm") #link_gcc_c_sequence  -specs=nosys.specs -specs=nano.specs
#set(CMAKE_EXE_LINKER_FLAGS "  -ereset_handler  -T${LINKER_SCRIPT} ") #link_gcc_c_sequence  -specs=nosys.specs -specs=nano.specs
##-A cortex-m4
